#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int n, k;
LL cnt[N], s[N];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &s[i]);
		s[i] += s[i - 1];
	}
	LL ans = 0;
	cnt[0] = 1;
	for (int i = 1; i <= n; i++) {	
		ans += cnt[s[i] % k];
		cnt[s[i] % k]++;
	}
	printf("%lld", ans);
	return 0;
}